/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.oai.metadataRepository.analysis;

import cz.mzk.oai.metadataRepository.metadata.MetadataFormat;
import cz.mzk.oai.metadataRepository.repository.collections.MetadataCollection;
import cz.mzk.oai.metadataRepository.repository.records.Record;
import java.util.List;

/**
 *
 * @author Martin Rehanek, Martin.Rehanek@gmail.com
 */
public class Analyzer {

    private final RecordsStatistics statistics;
    //private final Repository repository;
    private final MetadataCollection collection;
    private final MetadataFormat format;

    public Analyzer(Analysis analysis, MetadataCollection collection, RecordPrintOptions recordPrint) {
        this.collection = collection;
        this.format = analysis.getMetadataFormat();
        statistics = new RecordsStatistics(analysis, recordPrint);
    }

    public void analyzeAndPrintResults(boolean printValues, boolean printIds) {
        System.out.println("Collection: " + collection.getName());
        analyzeFiles();
        statistics.printResults(printValues, printIds);
    }

    private void analyzeFiles() {
        List<Record> records = collection.getRecords(format, null, null);
        for (Record record : records) {
            statistics.processRecord(record);
        }
    }
}
